import axios from 'axios';

const API_URL = 'http://localhost:8090/api/collections';

class CollectionsService {
  getAllCollections() {
    return axios.get(API_URL);
  }

  createCollection(collection) {
    return axios.post(API_URL, collection);
  }

  getCollectionById(id) {
    return axios.get(`${API_URL}/${id}`);
  }

  updateCollection(id, collection) {
    return axios.put(`${API_URL}/${id}`, collection);
  }

  deleteCollection(id) {
    return axios.delete(`${API_URL}/${id}`);
  }

  // 添加搜索方法
  searchCollections(params) {
    return axios.get(`${API_URL}/search`, {
      params: {
        orderId: params.orderId,
        approvalStatus: params.approvalStatus,
        overdueStatus: params.overdueStatus,
        paymentMethod: params.paymentMethod
      }
    });
  }
}

export default new CollectionsService();